import React, { useEffect, useState } from "react";
import ComA from './classRedux/ComA'
import ComB from './classRedux/ComB'
import axios from "axios";
import { Button } from 'antd'
export default function Home() {
  const [datalist, setDatalist] = useState([])
  const toReq = () => {
    axios.get('/goods/goodlist').then(res => {
      console.log(res.data.shopList)
      setDatalist(res.data.shopList)
    }).catch(err => console.log(err))
  }
  useEffect(() => {
    toReq()
  },[])
  return (
    <div style={{ width: "500px", display: "flex", flexDirection: 'column', alignItems: "center" }}>
      {/* 测试类组件获取/操作Redux中的数据 */}
      <ComA />
      <ComB />
      <Button type="primary" danger={true} onClick={toReq}>发送请求</Button>
      <div>
        <ul>
          <h5>测试axios请求</h5>
          {datalist.map(item => <li key={item.id}>{item.id}</li> )}
        </ul>
      </div>
    </div>
  )
}
